#include<iostream>
using namespace std;
template <class T> void InsertSort(T r[],int n);
template <class T>int length(T &arr);
template <class T>void print(T &arr);
int main()
{
    int a[]={6,4,2,7,61,4,2,72,4,2,7,6,4,2,75};
    InsertSort(a,length(a));
    print(a);
}
//升序排列
template <class T> void InsertSort(T r[],int n)
{
    for (int i = 2; i <= n; i++)
    {
        if (r[i]<r[i-1])
        {
            r[0]=r[i];
            r[i]=r[i-1];
            for (int j = i-2; r[0]<r[j]; j--)
            {
                r[j+1]=r[j];
                r[j+1]=r[0];
            }
        }
    }
}
//计算数组长度
template <class T>int length(T &arr)
{
    return sizeof(arr)/sizeof(arr[0]);
}
//打印数组元素
template <class T>void print(T &arr)
{
    for (int i = 0; i < length(arr); i++)
    {
        cout<<arr[i]<<" ";
    }
    cout<<endl;
}